package top.itaso.app.ui.mapview

import androidx.lifecycle.ViewModelProvider
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import com.itsdf07.cores.app.example.ui.fragment.mapview.MapViewViewModel
import top.itaso.app.R
import top.itaso.lib.widget.map.ChinaMapView

class MapViewFragment : Fragment() {

    companion object {
        fun newInstance() = MapViewFragment()
    }

    private lateinit var viewModel: MapViewViewModel
    private lateinit var chinaMapView: ChinaMapView
    private lateinit var btnDefaultMap: Button

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val rootView = inflater.inflate(R.layout.fragment_mapview, container, false)

        initView(rootView)
        return rootView
    }

    private fun initView(rootView: View) {
        chinaMapView = rootView.findViewById(R.id.view_mapview)
        btnDefaultMap = rootView.findViewById(R.id.btn_reset)
        btnDefaultMap.setOnClickListener {
            chinaMapView.setScale(0.1f)
        }

    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        viewModel = ViewModelProvider(this).get(MapViewViewModel::class.java)
        // TODO: Use the ViewModel
    }

}